/**
 * Ingenius-Group S.A.S
 *
 * Project: SAU
 * File: EditGuidelineView.java
 * Date: 04/02/2011
 */

package com.ingenius.sau.client.view;

import java.util.Date;

import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.ingenius.sau.client.presenter.EditGuidelinePresenter.EditGuidelineDisplay;

/**
 * Class <strong>EditGuidelineView</strong>
 * 
 * @author Jesus David
 * @version 0.1
 */
public class EditGuidelineView extends AbstractEditView implements
		EditGuidelineDisplay {

	// UI Widgets
	private final TextField<String> textName;
	private final TextField<String> textAuthor;
	private final TextArea textDescription;
	private final DateField dateField;

	// Constructor

	public EditGuidelineView() {
		super();
		textName = new TextField<String>();
		textAuthor = new TextField<String>();
		textDescription = new TextArea();
		dateField = new DateField();

		// TODO i18n
		setHeading("Edit Guideline");
		setSize(500, 330);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.views.AbstractEditView#createComponents()
	 */
	@Override
	protected void createComponents() {
		// TODO i18n
		FormData formData = new FormData("-20");
		textName.setFieldLabel("Name");
		textName.setAllowBlank(false);
		textName.addPlugin(plugin);
		textName.setData("text", "Enter the guideline name");
		textName.getMessages().setBlankText("Name is required");

		textDescription.setFieldLabel("Description");
		textDescription.setHeight(75);
		textDescription.setAllowBlank(false);
		textDescription.addPlugin(plugin);
		textDescription.setData("text", "Any description is fine...");
		textDescription.getMessages().setBlankText("Description is required");

		textAuthor.setFieldLabel("Author");
		textAuthor.setAllowBlank(false);
		textAuthor.addPlugin(plugin);
		textAuthor.setData("text", "Enter the author(s) name(s)");
		textAuthor.getMessages().setBlankText("Author is required");

		dateField.setFieldLabel("Date");
		dateField.setEditable(false);
		dateField.setAllowBlank(false);
		dateField.addPlugin(plugin);
		dateField.setData("text", "Select the publish date");
		dateField.getMessages().setBlankText("Date is required");

		form.add(textName, formData);
		form.add(textDescription, formData);
		form.add(textAuthor, formData);
		form.add(dateField, formData);
	}

	@Override
	public String getName() {
		return textName.getValue();
	}

	@Override
	public void setName(String name) {
		textName.setValue(name);
	}

	@Override
	public String getDescription() {
		return textDescription.getValue();
	}

	@Override
	public void setDescription(String description) {
		textDescription.setValue(description);
	}

	@Override
	public String getAuthorName() {
		return textAuthor.getValue();
	}

	@Override
	public void setAuthorName(String authorName) {
		textAuthor.setValue(authorName);
	}

	@Override
	public Date getDate() {
		return dateField.getValue();
	}

	@Override
	public void setDate(Date date) {
		this.dateField.setValue(date);
	}

}
